var pdf= "";
var xls= "";
Ext.define('NIM.view.AssetDataMaster.AddNewSiteMaster', {
      extend : 'Ext.panel.Panel',
      alias : 'widget.addnewsitemaster',
      id : 'addnewsitemaster',
      border : false,
      title : 'Add New Data List',
      border : false,
      height : 590,
      closable : true,
      layout : {
        type : 'border',
      },
      items : [{
            xtype : 'panel',
            id : 'ConfigAssetCategory1',
            title : 'Configuration',
            region : 'west',
            layout : 'card',
            margin : '5 5 5 5',
            collapsed : false,
            collapsible : true,
            width : 812,
            items : [
            	{
            	   id : 'assetMainForm',
                  xtype : 'AssetHeaderForm'
                },

            ]
          }, {
            xtype : 'panel',
            id : 'ConfigAssetCategory23',
            title : 'TreeView',
            region : 'east',
            margin : '5 5 5 5',
            layout : 'fit',
            collapsed : false,
            collapsible : true,
            width : 300,
            items : [{
            	
                  xtype : 'treepanel',
                  id : 'sitecategoriestree',
                  width : 370,
                  frame : true,
                  height : 480,
                  margin : '5 5 5 10 ',
                  rootVisible : false,
                  store : 'AssetDataMaster.Treeview',
                  dockedItems : [{
                        xtype : 'toolbar',
                        items : [
                             {
                              text : 'Expand',
	                             handler : function() {
	                                Ext.getCmp('sitecategoriestree').expandAll();
	                             }
                             }, 
                             {
                            	 text : 'Collapse',
                            	 handler : function() {
                            	 	Ext.getCmp('sitecategoriestree').collapseAll();
                              	 }
                             }, 
                             {
                            	 text : 'Add Category',
                            	 handler : function() {
                            	 	AddCategory();                                
                         		 }
                            }, 
                            {
                           	 	text : 'Delete Category',
                           	 	handler : function() {
                            		deleteCategory(); 
                        		}
                           }
                         ]
                      }],
                  listeners : {
            	  		
	                    itemdblclick : function(dv, record, item, index, e) {
		                      category = record.data.text;
		                      if(category.substring(0,4)=='SITE'){
		                    	  Ext.getCmp('assetMainForm').removeAll(true);
		                    	  Ext.getCmp('assetMainForm').add({ xtype : 'AssetHeaderForm' });
		                    	  Ext.getCmp('assetMainForm').doLayout();
		                      }else{
		                    	  category=record.data.text;
		                    	  Ext.Ajax.request({
		  					        method: "GET",
		  					        dataType: "json",
		  					        url: "./Services/DataMaster/AssetCategory?CATEGORY="+category,
		  					        async: false	,
		  					        success: function(c) {
		  					        	var jsonResults= $.parseJSON(c.responseText);
		  					        	var form = jsonResults.item[0].FORM;
		  					        	
		  					        	 if (form=="LAND"){
		 			                      	 pdf = "./Services/Asset/Report/Land/Pdf?SITE_ID=";
		 			                      	 xls = "./Services/Asset/Report/Land/Excel?SITE_ID=";
		 			                      		 
		  					        		 Ext.getCmp('assetMainForm').removeAll(true);
		 			                      	 Ext.getCmp('assetMainForm').add({ xtype : 'AssetLandForm'});
		 			                      	 Ext.getCmp('assetMainForm').doLayout();
		  			                      }else if (form =="TOWER"){
		 			                      	 pdf = "./Services/Asset/Report/Tow/Pdf?SITE_ID=";
		 			                      	 xls = "./Services/Asset/Report/Tow/Excel?SITE_ID=";
		  			                    	
		 			                      	 Ext.getCmp('assetMainForm').removeAll(true);
		  			                      	 Ext.getCmp('assetMainForm').add({ xtype : 'AssetTowerForm'});
		  			                      	 Ext.getCmp('assetMainForm').doLayout();
		  			                      }else if (form=="PLN"){
		 			                      	 pdf = "./Services/Asset/Report/PLN/Pdf?SITE_ID=";
		 			                      	 xls = "./Services/Asset/Report/PLN/Excel?SITE_ID=";
		  			                    	
		 			                      	 Ext.getCmp('assetMainForm').removeAll(true);
		 			                      	 Ext.getCmp('assetMainForm').add({ xtype : 'AssetPLNForm'});
		 			                      	 Ext.getCmp('assetMainForm').doLayout();
		  			                      }else{
		 			                      	 pdf = "./Services/Asset/Report/Site/Pdf?SITE_ID=";
		 			                      	 xls = "./Services/Asset/Report/Site/Excel?SITE_ID=";
		 			                      		 
		  			                    	 Ext.getCmp('assetMainForm').removeAll(true);
		 			                      	 Ext.getCmp('assetMainForm').add({ xtype : 'AssetNonSacGrid'});
		 			                      	 Ext.getCmp('assetMainForm').doLayout();
		  			                      }
		  					        	 
		  					        	
		  					            }
		  					    });
	                        
		                      }
	                    }
                  }
                }]
          }]
    });

var basic = Ext.create('Ext.create', 'Ext.resizer.Resizer', {
    target: 'ConfigAssetCategory1',
    width: 200,
    height: 100,
    minWidth:100,
    minHeight:50
});